Public Class adm_editterminalnumbers1
    Inherits System.Web.UI.Page
    'Protected WithEvents TheHeader1 As adm_header
    Public Msg, vid, uid As String
    Public aUserSession(13) As String
    Public oUtils As gaValidation
    Public strUserTermHtml, strUserUniqTermHtml As String
    Public tidcct, i As Integer
    Public aTerminals As Array
#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        'If aUserSession(cCOMPANY_ID) = "0" Then
        '    cid = safestring(Request("cid"))
        'Else
        '    cid = Application("CompanyID")
        'End If
        'If Request("vid").count > 0 Then
        '    vid = safestring(Request("vid"))
        '    uid = safestring(Request("uid"))

        'End If
        'Msg = ""
        'TheHeader1.whichpage = 53
        'TheHeader1.pageid = "editterminalnumbers"
        'TheHeader1.helpaid = ""
        'TheHeader1.iMenuLevel = -1
        'aUserSession = TheHeader1.security()
        'TheHeader1.StartInterface(53)
        'TheHeader1.intTopNavLev = 1 '''aTopNav(0, 5) = 1
        'aTopNav(1, 5) = 1
        'iMenuLevel = -1
        'Call StartInterface(53)
       
        'GetUserTeminal()
        'DetUserUniqTerm()
    End Sub
    Public Function PrintFriendlyMarket(ByVal which) As String
        Select Case which
            Case "I"
                PrintFriendlyMarket = "Internet Order"
            Case "M"
                PrintFriendlyMarket = "Mail Order / Telephone Order"
            Case "R"
                PrintFriendlyMarket = "Retail Order"
            Case Else
                PrintFriendlyMarket = "Uknown Market"
        End Select
    End Function

    Private Sub GetUserTeminal()

    '        oTerminals = CreateObject("viaUserManagement.UserManagement")
    '        oTerminals.DBConnectString = Application("DSN")
    '        aTerminals = oTerminals.GetUserTerminals(uid, vid, CInt(cid))
        '        tidcct = oTerminals.nTermCnt
        '      If tidcct > 0 Then
        '          ReDim aTids(tidcct)
        'end if%>
    '        <%		for i = 0 to ubound(aTerminals) - 1 step 1
    '				aTids(i) = aTerminals(i,2)%>
    '	<form action="adm_EditTerminalNumbers.asp" method="post">
    '	<tr><td nowrap valign="top">
    '		<font face="arial" size="2"><%=aTerminals(i,0)%>
    '		</font>
    '	</td><td nowrap valign="top">
    '		<font face="arial" size="2"><%=aTerminals(i,3)%>
    '		</font>
    '		</td><td nowrap valign="top">
    '		<font face="arial" size="2"><%=aTerminals(i,1)%>
    '		<input type="hidden" name="pin" value="<%=aTerminals(i,1)%>" size="4" maxlength="4">
    '        </font>
    '		</td>
    '		<td nowrap valign="top">
    '		<% if aTerminals(i,4) = "I" then
    '        printname = "Internet Order"
    '			elseif aTerminals(i,4) = "R" then
    '        printname = "Retail Order"
    '			elseif aTerminals(i,4) = "M" then
    '        printname = "MO/ TO"
    '			else
    '        printname = "Unknown"
    '			end if%>
    '		<font face="arial" size="2"><%=printname%></font>

    '	</td><td nowrap>
    '		<select name="length">
    '		<option value="6">six characters</option>
    '		<option value="5">five characters</option>
    '		<option value="4">four characters</option>
    '		</select>
    '	</td><td nowrap>
    '		<select name="type">
    '		<option value="Numpin">numeric</option>
    '		<option value="alphnum">alphanumeric</option>
    '		</select>
    '		</td><td nowrap>
    '		<input type="hidden" name="s" value="<%=request("s")%>">
    '		<input type="hidden" name="owner_uid" value="<%=aTerminals(i,0)%>">
    '		<input type="hidden" name="terminalNumber" value="<%=aTerminals(i,2)%>">
    '		<input type="hidden" name="uid" value="<%=uid%>">
    '		<input type="hidden" name="cid" value="<%=cid%>">
    '		<input type="hidden" name="vid" value="<%=vid%>">
    '		<input type="submit" name="action" value="Update">
    '		<input type="submit" name="action" value="Delete">
    '	</td></tr>
    '	<!--</form>-->
    '<%		NEXT
    '	end if %>
    End Sub

    Public Sub DetUserUniqTerm()
        '       <%if isELevelUser(vid, uid) then
        '       ownUid = vid

        'else
        '       ownUid = uid
        'end if

        '       If (aUserSession(cUSER_ID) <> uid) Then
        '           awnTerminals = oTerminals.GetUserUniqTerminals(ownUid, vid, CInt(cid), aUserSession(cUSER_ID))
        '       End If
        '       oTerminals = Nothing

        '       If IsArray(awnTerminals) And IsArray(aTids) Then

        '           oMerTids = CreateObject("Scripting.Dictionary")
        '           For i = 0 To UBound(awnTerminals) - 1 Step 1
        '               For a = 0 To UBound(aTids) - 1
        '                   If a <= UBound(aTids) - 1 Then
        '                       Do While awnTerminals(i, 0) <> aTids(a) And a <= UBound(aTids) - 1
        '                           a = a + 1
        '                       Loop
        '                       If UBound(aTids) - 1 = 0 And a > UBound(aTids) - 1 Then
        '                           a = a - 1

        '                       End If
        '                   End If
        '                   If a <= UBound(aTids) - 1 And awnTerminals(i, 0) <> aTids(a) Then
        '                       If Not IsNull(MerTids) Then
        '                           For Each Key In oMerTids
        '                               If awnTerminals(i, 0) = oMerTids(Key) Then
        '                                   Tid = oMerTids(Key)
        '                                   Exit For
        '                               End If
        '                           Next
        '                           If awnTerminals(i, 0) <> Tid Then
        '                               oMerTids.Add(awnTerminals(i, 1), awnTerminals(i, 0))

        '                           End If
        '                       Else

        '                           oMerTids.Add(awnTerminals(i, 1), awnTerminals(i, 0))

        '                       End If
        '                   End If

        '               Next
        '           Next
        'if oMerTids.Count > 0 then %>
        '			  		   <table class="minorbox">
        '					<form action="adm_EditTerminalNumbers.asp" method="post">
        '					<tr><td colspan="2" class="header">Add New Terminal Association</td>
        '					</tr>
        '					<tr><td nowrap valign="top">

        '			 		<select name="termNumber">
        ' 					<% if oMerTids.Count > 0 then
        ' 								for Each Key in oMerTids%>
        '			  			 	  	   <option value="<%=oMerTids(Key)%>"><%=Key%></option>
        '			  			 	  <%
        '        Next
        '			  		 end if%>

        '		   		</select>
        '			   </td>
        '			    <td nowrap>
        '			     	<input type="hidden" name="uid" value="<%=uid%>">
        '			     	<input type="hidden" name="cid" value="<%=cid%>">
        '			     	<input type="hidden" name="vid" value="<%=vid%>">
        '			     	<input type="hidden" name="s" value="<%=request("s")%>">
        '			     	<input type="submit" name="action" value="Add">
        '		     	</td></tr>
        '				</form>
        '			</table>
        '		<%end if
        '	else
        '		if Isarray(awnTerminals) then%>
        '					<table class="minorbox">
        '					<form action="adm_EditTerminalNumbers.asp" method="post">
        '					<tr><td colspan="2" class="header">Add New Terminal Association</td>
        '					</tr>
        '					<tr><td nowrap valign="top">
        '			 		<select name="termNumber">
        ' 					<%for i = 0 to ubound(awnTerminals) - 1 step 1%>
        '			  			<option value="<%=awnTerminals(i,0)%>"><%=awnTerminals(i,1)%></option>
        '			  		<%next%>

        '		   		</select>
        '			   </td>
        '			    <td nowrap>
        '			     	<input type="hidden" name="uid" value="<%=uid%>">
        '			     	<input type="hidden" name="cid" value="<%=cid%>">
        '			     	<input type="hidden" name="vid" value="<%=vid%>">
        '			     	<input type="hidden" name="s" value="<%=request("s")%>">
        '			     	<input type="submit" name="action" value="Add">
        '		     	</td></tr>
        '				</form>
        '			</table>
        '		<%end if
    End Sub
    Private Sub UpdateTerminal()
        '    If Request("action") = "Update" Then
        '        terminalNumber = safestring(Request("terminalNumber"))
        '        pin = safestring(Request("pin"))
        '        suid = safestring(Request("owner_uid"))
        '        If Request("length").count > 0 Then
        '            pinlength = safestring(Request("length"))
        '            pintype = safestring(Request("type"))
        '        End If

        '        oupd = CreateObject("viaUserManagement.UserManagement")
        '        oupd.DBConnectString = Application("DSN")
        '        oupd.pinlength = pinlength
        '        oupd.pintype = pintype
        '        oupd.SESSION_USER_ID = aUserSession(cUSER_ID)
        '        oupd.SESSION_VIAKLIX_ID = aUserSession(cVIAKLIX_ID)
        '        oupd.SESSION_COMPANY_ID = aUserSession(cCOMPANY_ID)
        '        newpin = oupd.UpdateTerminalAssoc(suid, vid, CInt(cid), terminalNumber, pin)
        '        If newpin <> "" Then
        '            notifymsg = "Pin number " & pin & " susccessfully changed to new pin " & newpin & "."
        '        Else
        '            Msg = "Pin number update failed."
        '        End If


        '    ElseIf Request("action") = "Add" Then
        '        terminalNumber = safestring(Request("termNumber"))
        '        If Len(terminalNumber) > 22 Or Len(terminalNumber) < 7 Then
        '            Msg = "Terminal Number cannot exceed 22 and must be more than 7 characters in length."
        '        Else
        '            uid = safestring(Request("uid"))
        '            oadd = CreateObject("viaUserManagement.UserManagement")
        '            oadd.DBConnectString = Application("DSN")
        '            oadd.SESSION_USER_ID = aUserSession(cUSER_ID)
        '            oadd.SESSION_VIAKLIX_ID = aUserSession(cVIAKLIX_ID)
        '            oadd.SESSION_COMPANY_ID = aUserSession(cCOMPANY_ID)
        '            oaddOk = oadd.AddUserTerminals(uid, vid, CInt(cid), terminalNumber)
        '            If oaddOk Then
        '                notifymsg = "Terminal " & terminalNumber & " successfully added."
        '            Else
        '                Msg = "Terminal addition failed."
        '            End If
        '        End If
        '    ElseIf Request("action") = "Delete" Then
        '        terminalNumber = safestring(Request("terminalNumber"))
        '        odelete = CreateObject("viaUserManagement.UserManagement")
        '        odelete.DBConnectString = Application("DSN")
        '        odelete.SESSION_USER_ID = aUserSession(cUSER_ID)
        '        odelete.SESSION_VIAKLIX_ID = aUserSession(cVIAKLIX_ID)
        '        odelete.SESSION_COMPANY_ID = aUserSession(cCOMPANY_ID)
        '        odeleteOk = odelete.DeleteTerminalAssoc(Request("owner_uid"), vid, CInt(cid), terminalNumber)
        '        If odeleteOk Then
        '            notifymsg = "Terminal " & terminalNumber & " and  pin number " & Request("pin") & " successfully deleted."
        '        Else
        '            Msg = "Terminal and pin number deletion failed."
        '        End If
        '    End If
    End Sub
End Class
